AC_INIT(nutss, 0.1.0, saikat@cs.cornell.edu)

echo "Configuring NUTSS:"

AC_CONFIG_SRCDIR(src/main.cpp)

AM_INIT_AUTOMAKE

AC_PROG_CC
AC_PROG_CXX
C_PROG_LIBTOOL

AC_CONFIG_HEADER(include/config.h)

CFLAGS="$CFLAGS -DLINUX"

dnl ============================
dnl Check for required libraries
dnl ============================

#AC_SEARCH_LIBS(pthread_atfork, pthread, [], [AC_ERROR(Requires pthreads)])
#AC_SEARCH_LIBS(eXosip_default_action, eXosip2, [], [AC_ERROR(Requires eXosip2)])
#AC_SEARCH_LIBS(uuid_generate, uuid, [], [AC_ERROR(Requires libuuid)])
#AC_SEARCH_LIBS(SSL_CTX_new, ssl, [], [AC_ERROR(Requires openssl)])
#AC_SEARCH_LIBS(deflateInit_, z, [], [AC_ERROR(Requires zlib)])
#AC_SEARCH_LIBS(event_add, event, [], [AC_ERROR(Requires libevent)])
AC_SEARCH_LIBS(ev_io_start, ev, [], [AC_ERROR(Requires libev)])

# Osip2
#AC_SEARCH_LIBS(osip_message_free, osip2, [], [AC_ERROR(Requires osip2)])
#if pkg-config --atleast-version=3.0.0 libosip2; then
#    AC_DEFINE(HAVE_OSIP2_3, 1, [Osip2 > 3.0])
#fi
#CFLAGS="$CFLAGS $(pkg-config --cflags libosip2)"

#AC_SEARCH_LIBS(XSetAuthorization, X11,
#    [AC_DEFINE(HAVE_XAUTH, 1, [Xauth])
#     s_xauth=t
#     ])
#AM_CONDITIONAL(HAVE_XAUTH, test x$s_xauth = xt)

#AC_SEARCH_LIBS(xmlDOMWrapCloneNode, xml2, [], [AC_ERROR(Requires libxml2 >= 2.6.27)])
#AC_CHECK_HEADER(libxml/parser.h, [], [
#CFLAGS="$CFLAGS $(xml2-config --cflags) -Wno-pointer-sign"
#])

dnl =========
dnl Debugging
dnl =========
AC_MSG_CHECKING([for compilation with debugging])
AC_ARG_ENABLE(debug,
[  --enable-debug          compile with debugging support],
	debug_enabled=t)

if test x$debug_enabled = xt; then
    #no optimization wanted
	CFLAGS="${CFLAGS/O2/O0} -g -DDEBUG"
    AC_MSG_RESULT([yes])
else
    AC_MSG_RESULT([no])
fi


dnl ======================================
dnl Recursive configure and generate files
dnl ======================================

#AC_CONFIG_SUBDIRS([dante])

dnl =======
dnl Doxygen
dnl =======

#DX_HTML_FEATURE(ON)
#DX_CHM_FEATURE(OFF)
#DX_CHI_FEATURE(OFF)
#DX_MAN_FEATURE(ON)
#DX_RTF_FEATURE(OFF)
#DX_XML_FEATURE(OFF)
#DX_PDF_FEATURE(OFF)
#DX_PS_FEATURE(OFF)
#DX_INIT_DOXYGEN(nutss, doxygen.cfg, doc/doxygen)

dnl ===============
dnl Generate output
dnl ===============

AC_OUTPUT([Makefile src/Makefile])
# include/Makefile patches/Makefile
#           examples/Makefile doc/Makefile scripts/Makefile VERSION nutss.spec
#           scripts/nutssify], [chmod +x scripts/nutssify])
